package com.barneyx.mshinfoplatform.entity.user;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.barneyx.mshinfoplatform.entity.CommonEntity;
import com.barneyx.mshinfoplatform.entity.enums.ESex;
import com.barneyx.mshinfoplatform.entity.enums.EUserState;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.TableCharset;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

@TableName("msh_users")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("用户表")
@TableCharset(MySqlCharsetConstant.UTF8MB4)
public class UserEntity extends CommonEntity implements Serializable {
    @TableId(value = "user_id", type = IdType.ASSIGN_ID)
    @Column(type = MySqlTypeConstant.BIGINT)
    private String UserId;

    @TableField("is_vip")
    @Column(type = MySqlTypeConstant.BIT)
    private Boolean IsVip;

    @TableField("user_name")
    private String UserName;

    @ApiModelProperty(value = "推荐人")
    @Column(defaultValue = "0", type = MySqlTypeConstant.BIGINT)
    @TableField("parent_user_id")
    private String ParentUserId;

    @TableField("user_nickname")
    private String UserNickName;

    @TableField("user_via")
    @Column(defaultValue = "https://imgs.nxhmmr.com/msh/via/def-user-via.jpg")
    private String UserVia;

    @TableField("is_lock")
    private Boolean IsLock;

    @TableField("user_sex")
    @Column(type = MySqlTypeConstant.TINYINT)
    private ESex UserSex;

    @TableField("user_state")
    @Column(type = MySqlTypeConstant.TINYINT)
    private EUserState State;

    @TableField("user_phone")
    @Unique
    @NotBlank
    @Column(isNull = false, type = MySqlTypeConstant.CHAR, length = 20)
    private String UserPhone;

    @TableField("user_pwd")
    private String UserPwd;

    @TableField("last_login_at")
    @Column(type = MySqlTypeConstant.DATETIME)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date LastLoginAt;


    @TableField("idcard")
    public String IdCard;

}
